# -*- coding: utf-8 -*-
'''
Created on 14 de Abr de 2011

@author: Carlos Alexandre Rijo Palma Nº5608 \
         Curso: Eng Informática Regime: Diurno \
         Cadeira: Linguagens Programação 2ºANO
'''
import SimpleHTTPServer
import SocketServer
import threading
import urllib

#class servidor http
#faz a conexão a um servidor http local
class Servidor:
    def __init__(self):
        self.server()
        pass
    
    def server(self):    
        PORT = 8001
        
        handler = SimpleHTTPServer.SimpleHTTPRequestHandler
            
        httpd = SocketServer.TCPServer(("", PORT), handler)
            
        httpd_thread = threading.Thread(target=httpd.serve_forever)
        httpd_thread.setDaemon(True)
        httpd_thread.start()
            
        api_data = urllib.urlopen("http://localhost:8001/home/admin1/index.html")
        print "Data start:"
        #print html.load(api_data)